<!-- 账单 -->
<template>
  <div class="Bill">
    <!-- 顶部导航栏 吸顶 -->
    <van-sticky>
      <van-nav-bar title="我的账单">
        <template #left>
          <van-icon name="arrow-left" color="#fff" @click="goBack">返回</van-icon>
        </template>
      </van-nav-bar>
      <div class="avatar">
        <van-image width="100px" height="100px" :src="avatar"/>
      </div>
      <div class="name">{{nickname}}</div>
    </van-sticky>

    <!-- 账单部分 -->
    <div class="box">
      <van-swipe-cell v-for="(item,index) in bill" :key="index">
        <router-link :to="`/billDetails/${index}`">
          <van-card :title="item.state?'充值金额':'消费金额'" :desc="item.describe" :price="item.time"  :thumb="avatar" >
          </van-card>
          <div class="money" style="color: #F8C40B;" v-if="item.state">+{{item.price.toFixed(2)}}</div>
          <div class="money" v-else>{{item.price.toFixed(2)}}</div>
        </router-link>
      </van-swipe-cell>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  data(){
    return{

    }
  },
  computed:{
    ...mapState(["avatar","nickname","bill"]),
  },
  methods:{
    // 返回
    goBack() {
      this.$router.go(-1);
    },
  }
}
</script>

<style lang="scss" scoped>
.Bill{
  .van-nav-bar{
    background-color: $base-color;
    ::v-deep .van-nav-bar__title{
      font-weight: bold;
    }
    .van-icon{
      font-weight: bold;
    }
  }
  ::v-deep .van-nav-bar__right{
    color: #fff;
    font-weight: bold;
  }
  .avatar{
    display: flex;
    justify-content: center;
    margin-top: 20px;
  }
  .name{
    text-align: center;
    font-weight: bold;
    margin: 10px;
  }
  .box{
    height: calc(100vh - 207px);
    overflow-x: hidden;
    overflow-y: overlay;
    .van-card__content{
      justify-content: center;
      padding-left: 5px;
      .van-card__title{
        font-size: 16px;
        font-weight: bold;
        line-height: 20px;
      }
      .van-card__desc{
        font-size: 15px;
        padding: 10px 0;
      }
      .van-card__price-currency{
        display: none;
      }
      .van-card__price{
        color: #fff;
        .van-card__price-integer{
          color: #646566;
        }
      }
    }
    .money{
      position: absolute;
      right: 18px;
      top: 43px;
      color: #000;
    }
  }
}
</style>